//jquery로 수정
//try ~ catch구문을 이용해 newBtn, writeBtn다 먹히게~
try{
	var writeBtn = document.getElementById("listBtn");
	writeBtn.onclick = function(){
		go2list();
	}
}catch(e){}
try{
	
	var newBtn = document.getElementById("newBtn");
	newBtn.onclick = function(){
		go2write();
	}
}catch(e){}
try{
	var writeBtn = document.getElementById("writeBtn");
	writeBtn.onclick = function(){
		go2writeok();
	}
}catch(e){}

try{
	var delBtn = document.getElementById("delBtn");
	delBtn.onclick = function(){
		go2del();
	}
}catch(e){}

try{
	var updateBtn = document.getElementById("updateBtn");
	updateBtn.onclick = function(){
		go2update();
	}
}catch(e){}


try{
	var updokBtn = document.getElementById("updokBtn");
	updokBtn.onclick = function(){	
			go2updateok();
	}
}catch(e){}

function go2write(){location.href="write.jsp";}

function go2writeok(){
	var writefrm = document.getElementById("writefrm");
	var bdtitle = document.getElementById("bdtitle");

	//기입하라는 메세지  꼭 필요!!!
	if(bdtitle.value==""){
		alert('제목을 기입하세요!!');
	}else if(bdcontents.value==""){
		alert('내용을 기입하세요!!')
	}else{
		writefrm.action="writeok.jsp";
		writefrm.method="post";
		writefrm.submit();	
	}
}

function go2list(){location.href="list.jsp";}

function go2del(){
	if(confirm("정말로 삭제하시겠습니까?")){
		var bdno = document.getElementById("bdno").value;
		location.href="delete.jsp?bdno="+bdno;
		}
	}

function go2update(){
	var bdno = document.getElementById("bdno").value;
	location.href="update.jsp?bdno="+bdno;
}

function go2updateok(){
	if(confirm("정말로 수정하시겠습니까?")){
		var updateokfrm = document.getElementById("updatefrm");
		var bdno = document.getElementById("bdno").value;
		
		updateokfrm.action="updateok.jsp?bdno="+bdno;
		updateokfrm.method="post";
		updateokfrm.submit();	
	}

		
	
}
